package com.neuedu.my12306.web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.neuedu.my12306.entity.StationInfo;
import com.neuedu.my12306.service.IStationInfoService;
import com.neuedu.my12306.util.SpringContextUtil;
import com.neuedu.my12306.util.StringUtil;

/**
 * Servlet implementation class ToEditStationServlet
 */
@WebServlet("/ToEditStationServlet.do")
public class ToEditStationServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    private IStationInfoService stationInfoService;  
    public ToEditStationServlet() {
        super();
        stationInfoService = SpringContextUtil.getBean("stationService", IStationInfoService.class);
		//stationInfoService = new IStationInfoServiceImpl();
       
    }


	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//1.在接收数据前进行编码转换(统一使用过滤器转换)
		String  tid = request.getParameter("id");
		int id = StringUtil.parseInt(tid, 0);
		StationInfo stationInfo = stationInfoService.findStationInfoById(id);
		
		request.setAttribute("station", stationInfo);
		request.getRequestDispatcher("Admin/StationManageInfo_Amin_Edit.jsp").forward(request, response);
		
	}

}
